<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<%@page import="com.blockchain.front.servlets.trading.ajax.UserAccount"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.UserZh"%>
<%@page import="com.blockchain.front.service.trading.entity.ZhEntity"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.XxWdWt"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.TradingMc"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.Wdwt"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.TradingMr"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.JymmExists"%>
<%@page import="com.blockchain.front.servlets.security.Jymmsz"%>
<%@page import="com.blockchain.front.service.trading.entity.HqEntity"%>
<%@page import="com.blockchain.front.service.trading.entity.WtEntity"%>
<%@page import="com.blockchain.common.enums.JymmType"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.WtCjjl"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.WtMc"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.WtMr"%>
<%@page import="com.blockchain.front.servlets.trading.ajax.Hq"%>
<%@page import="com.blockchain.front.service.trading.entity.XlbEntity"%>
<%@page import="com.blockchain.front.servlets.financial.CxWt"%>
<%@page import="com.blockchain.front.service.financial.entity.JlEntity"%>
<%@page import="com.blockchain.front.service.trading.TradingManage"%>
<%@page import="com.blockchain.front.service.financial.entity.UserZhEntity"%>
<%@page import="com.blockchain.front.service.financial.FinancialManage"%>
<%@page import="com.blockchain.common.enums.IsPass"%>
<%@page import="com.blockchain.front.servlets.LoginVerify"%>
<%@page import="com.blockchain.front.servlets.trading.Trading"%>
<%@page import="com.blockchain.front.servlets.trading.index"%>
<%@page import="com.blockchain.common.enums.JyztStatus"%>
<%@page import="com.blockchain.front.service.security.entity.QbdzEntity"%>
<html>
<head>
<%
	String str = languageDefine.getValue(request, "menu_tradeCenter");
	String _TITLE_ = str+"- "+configureProvider.getProperty(SystemVariable.SITE_NAME);
	CURRENT_SUB_CATEGORY = "JYZX";
	int scid=IntegerParser.parse(request.getParameter("id"));
	FinancialManage financialManage=serviceSession.getService(FinancialManage.class);
	TradingManage tradingManage=serviceSession.getService(TradingManage.class);
	String mmsrsz="";
	if (blockchainSession == null || blockchainSession.isAuthenticated()) {
		mmsrsz=tradingManage.getMmsr();
	}
	XlbEntity b=tradingManage.getB(scid);
	WtEntity[] cjs= tradingManage.getCjjl(scid,0);
	HqEntity[] hqlist= tradingManage.hqList();
	JYZX_SELECT_TABLE_INDEX = 0;
%>
<title><%=_TITLE_ %></title>
<%@include file="/WEB-INF/include/meta.jsp"%>
<%@include file="/WEB-INF/include/style.jsp"%>
<%@include file="/WEB-INF/include/sfrz.jsp"%>
</head>
<body>
	<div class="header bg_w"
		style="position: fixed; z-index: 99; height: 120px;">
		<!--头部-->
		<%@include file="/WEB-INF/include/trading/header.jsp"%>
		<!--交易行情-->
		<%@include file="/WEB-INF/include/trading/hq.jsp"%>
	</div>
	<!--菜单-->
	<%@include file="/WEB-INF/include/trading/left.jsp"%>
	<!--行情图-->
	<%@include file="/WEB-INF/include/trading/hqt.jsp"%>
	<div class="autobox mt20 clear" id="Kline-change"
		style="margin-top: -20px;">

		<div class="trade-market-box fl w798">
			<div class="purchase-box buy-input-box mt14 h136">
				<spna class="pur-tip buy"><%=languageDefine.getValue(request, "trading_buy")%></spna>
				<div class="pur-input-box">
					<p class="c-number">
						<span class="usa"><%=languageDefine.getValue(request, "accountStatus_available")%>
							<%=b.ywm_m.equalsIgnoreCase("USDZ")?b.ywm_m:b.ywm_m%>：<i
							id="my_rmb" class="">0</i></span><span><%=languageDefine.getValue(request, "accountStatus_freeze")%>
							<%=b.ywm_m.equalsIgnoreCase("USDZ")?b.ywm_m:b.ywm_m%>： <font
							id="my_rmbd">0</font></span>
					</p>
					<div class="input-box mt10">
						<label>
	                        <p style="width: auto;position: absolute;margin-left: 73px; float: none;right: initial;
	                        color: #777777;top: 80px;font-size: 10px;">
	                        <span style="font-size:10px;padding:0px 3px;" id="buy_best_price"></span>
	                        <%=null==b.ywm_m?"":b.ywm_m%></p>
						<input type="text" id="buy_price"
							class="pur-input"
							name="price" autocomplete="off" aria-autocomplete="none" value=""
							onkeyup="my_je_zj();mr_max_km();this.value=this.value.replace(/[^0-9.]/g,'');value=value.replace(/\.\d{<%=b.ws + 1 %>,}$/,value.substr(value.indexOf('.'),<%=b.ws+ 1 %>));">
						
						</label> <span> × </span> <label> 
						<input type="text" class="pur-input"
							placeholder="<%=languageDefine.getValue(request, "trading_buyQuantity")%>"
							id="buy_num" name="num" autocomplete="off"
							aria-autocomplete="none"
							onkeyup="zj('<%=1%>');this.value=this.value.replace(/[^0-9.]/g,'');value=value.replace(/\.\d{<%=b.slws + 1 %>,}$/,value.substr(value.indexOf('.'),<%=b.slws + 1%>));">
						</label> <span></span> <label>(<%=Formater.formatAmount_(b.mr_sxfl.multiply(new BigDecimal(100)),3)%>%
							<%=languageDefine.getValue(request, "trading_fee")%> )
						</label> <span> = </span> <label class="number"><font
							class="col_333" id="zj_mum">0</font> <%=b.ywm_m.equalsIgnoreCase("USDZ")?b.ywm_m:b.ywm_m%></label>
					</div>
					<div class="input-box mt20">
					
						<%if(!StringHelper.isEmpty(mmsrsz)&&mmsrsz.equals(JymmType.MBJY.toString())){%>
						<label style="margin-right: 36px;"><input type="password"
							id="buy_paypassword" class="pur-input"
							name=""></label>
						<%}%>
						<%if (blockchainSession == null || !blockchainSession.isAuthenticated()) {%>
						<label><input type="button" class="submit-btn buy-btn"
							placeholder="<%=languageDefine.getValue(request, "trading_tradePassword")%>"
							value='<%=languageDefine.getValue(request, "trading_buy")%>'
							onclick="loginpop('<%=controller.getURI(request, LoginVerify.class)%>');"></label>
						<%}else{%>
						<label><input type="button" class="submit-btn buy-btn"
							value='<%=languageDefine.getValue(request, "trading_buy")%>'
							onclick="tradeadd_buy();"></label>
						<%}%>
					</div>
				</div>
				<%if(!StringHelper.isEmpty(mmsrsz)&&mmsrsz.equals(JymmType.MBJY.toString())){%>
				<img class="set-pay-possword" src="/images/set-btn-icon.png">
				<%}%>
			</div>
			<div class="purchase-box sell-input-box mt14 h136">
				<spna class="pur-tip sell"><%=languageDefine.getValue(request, "trading_sell")%></spna>
				<div class="pur-input-box">
					<p class="c-number">
						<span class="usa"><%=languageDefine.getValue(request, "accountStatus_available")%>
							<%StringHelper.filterHTML(out,b.zwm_s);%>：<i id="my_xnb" class="">0</i></span><span><%=languageDefine.getValue(request, "accountStatus_freeze")%>
							<%StringHelper.filterHTML(out,b.zwm_s);%>：<font id="my_xnbd">0</font></span>
					</p>
					<div class="input-box mt10">
						<label> 
						<p style="top: 80px;width:auto;position: absolute;margin-left: 73px; float: none;right: initial;color: #777777;font-size: 10px;">
	                    <span style="font-size:10px;padding:0px 3px;" id="sell_best_price"></span><%=null==b.ywm_m?"":b.ywm_m%></p>
						<input type="text" id="sell_price"
							class="pur-input"
							autocomplete="off" aria-autocomplete="none" name="price"
							onkeyup="mc_je_zj();this.value=this.value.replace(/[^0-9.]/g,'');value=value.replace(/\.\d{<%=b.ws + 1 %>,}$/,value.substr(value.indexOf('.'),<%=b.ws + 1 %>));" />  
	                        
						</label> <span> × </span> <label><input type="text" id="sell_num"
							name="num" class="pur-input"
							placeholder="<%=languageDefine.getValue(request, "trading_sellQuantity")%>"
							autocomplete="off" aria-autocomplete="none"
							onkeyup="zj('<%=2%>>');this.value=this.value.replace(/[^0-9.]/g,'');value=value.replace(/\.\d{<%=b.slws + 1 %>,}$/,value.substr(value.indexOf('.'),<%=b.slws + 1 %>));"></label>
						<span></span> <label>(<%=Formater.formatAmount_(b.mc_sxfl.multiply(new BigDecimal(100)),3)%>%
							<%=languageDefine.getValue(request, "trading_fee")%> )
						</label> <span> = </span> <label class="number"><font
							id="zj_sell_mum">0</font> <%=b.ywm_m.equalsIgnoreCase("USDZ")?b.ywm_m:b.ywm_m%></label>
					</div>
					<div class="input-box mt20">
						<%if(!StringHelper.isEmpty(mmsrsz)&&mmsrsz.equals(JymmType.MBJY.toString())){%>
						<label style="margin-right: 36px;"><input
							id="sell_paypassword" name="pwtrade" type="password"
							class="pur-input"
							placeholder="<%=languageDefine.getValue(request, "trading_tradePassword")%>"></label>
						<%}%>
						<%if (blockchainSession == null || !blockchainSession.isAuthenticated()) {%>
						<label><input class="submit-btn sell-btn" type="button"
							value='<%=languageDefine.getValue(request, "trading_sell")%>'
							onclick="loginpop('<%=controller.getURI(request, LoginVerify.class)%>');"></label>
						<%}else{%>
						<label><input class="submit-btn sell-btn" type="button"
							value='<%=languageDefine.getValue(request, "trading_sell")%>'
							onclick="tradeadd_sell();"></label>
						<%}%>
					</div>
				</div>
				<%if(!StringHelper.isEmpty(mmsrsz)&&mmsrsz.equals(JymmType.MBJY.toString())){%>
				<img class="set-pay-possword" src="/images/set-btn-icon.png">
				<%}%>
			</div>
			<!--<div class="no-login"></div>-->
			<!--<div class="login-tip"><p>您还没有登录!<a href="/Login/">登录</a>-->
			<!--</p></div>-->			
		</div>


		<!--账户资产-->
		<%-- <%@include file="/WEB-INF/include/trading/zhzc.jsp"%> --%>
		<!--买入卖出-->
		<%-- <%@include file="/WEB-INF/include/trading/mrmc.jsp"%> --%>
		<div class="right w390">
			<!--委托-->
			<%@include file="/WEB-INF/include/trading/wt.jsp"%>
		</div>
	</div>
	<!--我的委托-->
	<%@include file="/WEB-INF/include/trading/wdwt.jsp"%>
	<!--成交记录-->
	<%@include file="/WEB-INF/include/trading/cjjl.jsp"%>
	<%@include file="/WEB-INF/include/footer.jsp"%>
	<%@include file="/WEB-INF/include/script.jsp"%>
	<script type="text/javascript">
	var scid=<%=scid%>;
	var hq_url='<%=controller.getURI(request,Hq.class)%>';
	var wd_mr_url='<%=controller.getURI(request,WtMr.class)%>';
	var wd_mc_url='<%=controller.getURI(request,WtMc.class)%>';
	var wtcjjl_url='<%=controller.getURI(request,WtCjjl.class)%>';
	var jymm_url='<%=controller.getURI(request,JymmExists.class)%>';
	var trading_mr_url='<%=controller.getURI(request,TradingMr.class)%>';
	var wdwt_url='<%=controller.getURI(request,Wdwt.class)%>';
	var trading_mc_url='<%=controller.getURI(request,TradingMc.class)%>';
	var cxwt_url='<%=controller.getURI(request,XxWdWt.class)%>';
	var zh_url='<%=controller.getURI(request,UserZh.class)%>';
	var xlb_ky=0;//账户可用虚拟币
	var cny_ky=0;//账户可用人民币
	$(function(){
		hq();//行情2
		mr();//买入1
		mc();//卖出1
		cjjl();//成交记录  5
		window.setInterval("mr();mc();",1000);
		window.setInterval("hq();",2000);
		window.setInterval("cjjl();",5000);
		<%if (blockchainSession == null || blockchainSession.isAuthenticated()) {%>
		zh();//我的账户信息
		wdwt();//我的委托;
		window.setInterval("wdwt();",1000);
		window.setInterval("zh();",3000);
		<%}%> 
		$(".set-pay-possword").click(function() {
			window.location = "<%=controller.getViewURI(request, com.blockchain.front.servlets.security.Jymmsz.class)%>";
		});
	});
	
	function zh(){//我的账户信息
		var data = {"scid" : scid};
		$.ajax({
			type : "post",
			dataType : "html",
			url : zh_url,
			data : data,
			success : function(data) {
				var ct = eval('(' + data + ')');
				if (ct.num>0) {
					$("#my_xnb").html(ct.msg.xlb_ky);
					$("#my_xnbd").html(ct.msg.xlb_dj);
					<%if(!b.ywm_m.equalsIgnoreCase("USDZ") && !b.ywm_m.equalsIgnoreCase("USDZ")){%>	
						$("#my_rmb").html(ct.msg.usable_virtualCoin);	
						$("#my_rmbd").html(ct.msg.frozen_virtualCoin);
					<%}else{%>
						$("#my_rmb").html(ct.msg.cny_ky);	
						$("#my_rmbd").html(ct.msg.cny_dj);
					<%}%>
					/* $("#zdkm").html(ct.msg.xlb_ky); */
					xlb_ky=ct.msg.xlb_ky;
					cny_ky=ct.msg.cny_ky;
				}
				console.log(data);
			}
		});
	}
		
	function hq(){//行情
	var data = {"scid" : scid};
		$.ajax({
			type : "post",
			dataType : "html",
			url : hq_url,
			data : data,
			success : function(data) {
				var ct = eval('(' + data + ')');
				if (ct.num>0) {
				$("#market_new_price").html(ct.msg.dqj);
				$("#market_max_price").html(ct.msg.zgj);
				$("#market_min_price").html(ct.msg.zdj);	
				$("#market_buy_price").html(ct.msg.mr_yj);
				$("#market_sell_price").html(ct.msg.mc_yj);
				$("#market_volume").html(ct.msg.cjl);
				$("#market_change").html(ct.msg.rzd+"%");
				$("#sell_best_price").html(ct.msg.mr_yj);
				$("#buy_best_price").html(ct.msg.mc_yj);
				if(ct.msg.rzd>0){
					$('#market_change').removeClass('text_red');
				    $('#market_change').addClass('green');
				}
				scid=ct.msg.scid;
				}
			}
		});
	}

function mr(){//买入
	var data = {"scid" : scid};
	 $.ajax({
			type : "post",
			dataType : "html",
			url : wd_mr_url,
			data : data,
			success : function(data) {
				var ct = eval('(' + data + ')');
				if (ct.num>0) {
					var content = "";
					var count = ct.msg.length;
					if(ct.msg.length > 9){
						count = 10;
					}
				for(var i=0;i<count;i++){
				var jg=ct.msg[i].jg.replace(",",""); 
				var s='<dl title="<%=languageDefine.getValue(request, "js_thisPriceBuy")%>" style="cursor: pointer;" onclick="buy_ell('+jg+',1);">';
					s+='<dt class="buy" style="width: 40px;padding-left: 5px;">'+'<%=languageDefine.getValue(request, "js_buy")%>'+(i+1)+'</dt>';
					s+='<dd class="buy" style="width: 90px" >'+ct.msg[i].jg+'</dd>';
					s+= '<dd class="buy" style="width: 110px">'+ct.msg[i].sl+'</dd>';
					s+='<dd class="buy" style="width: 100px">'+ct.msg[i].ze+'</dd>';
					s+='</dl>';
					content+=s;
				}	
				$("#buylist").html(content);
				}
			}
		});
		
}

	function mc() {//卖出
		var data = {
			"scid" : scid
		};
		$.ajax({
					type : "post",
					dataType : "html",
					url : wd_mc_url,
					data : data,
					success : function(data) {
						var ct = eval('(' + data + ')');
						if (ct.num > 0) {
							var content = "";
							for (var i = (ct.msg.length>10?9:ct.msg.length-1); i>=0 ; i--) { 
								 var jg=ct.msg[i].jg.replace(",",""); 
								var s = '<dl title="'+'<%=languageDefine.getValue(request, "js_thisPriceSell")%>'+'" style="cursor: pointer;"  onclick=" buy_ell('+jg+',2);">';
								s += '<dt class="sell" style="width: 40px;padding-left: 5px;">'+'<%=languageDefine.getValue(request, "js_sell")%>'
										+ (i+1) + '</dt>';
								s += '<dd class="sell"    style="width: 90px">'
										+ ct.msg[i].jg + '</dd>';
								s += '<dd class="sell" style="width: 110px">'
										+ ct.msg[i].sl + '</dd>';
								s += '<dd class="sell" style="width: 100px">'
										+ ct.msg[i].ze + '</dd>';
								s += '</dl>';
								content += s;
							}
							$("#selllist").html(content);
						}
					}
				});
	}
	
	function cjjl() {//成交记录 
		var data = {
			"scid" : scid
		};
		$.ajax({
			type : "post",
			dataType : "html",
			url : wtcjjl_url,
			data : data,
			success : function(data) {
				var ct = eval('(' + data + ')');
				if (ct.num > 0) {
					var content = "";
					for (var i = 0; i < ct.msg.length; i++) {
						var s = '<tr>';
						s += '<td  class='+ct.msg[i].cs+' width="180">'
								+ ct.msg[i].sj + '</td>';
						s += '<td  class='+ct.msg[i].cs+' width="80">';
						if(ct.msg[i].type=="买入") {
							s+='<%=languageDefine.getValue(request, "js_myBuy")%>';
						}
						else {
							s+='<%=languageDefine.getValue(request, "js_mySell")%>';
						}
						
						s += '</td>';
						s += '<td  class='+ct.msg[i].cs+' width="250">'
								+ ct.msg[i].jg + '</td>';
						s += '<td  class='+ct.msg[i].cs+' width="250">'
								+ ct.msg[i].sl + '</td>';
						s += '<td  class='+ct.msg[i].cs+' >' + ct.msg[i].ze
								+ '</td>';
						s += '</tr>';
						content += s;
					}
					$("#orderlist").html(content);
				}
			}
		});
	}

	

	function wdwt(){//我的委托
	var data = {"scid" : scid};
	$.ajax({
		type : "post",
		dataType : "html",
		url : wdwt_url,
		data : data,
		success : function(data) {
			 var ct = eval('(' + data + ')');
			if (ct.num>0) {
				 var content = "";
				for (var i = 0; i < ct.msg.length; i++) {
					var s = '<tr>';
					s+= '<td width="180" class="'+ct.msg[i].ys+'">'+ct.msg[i].sj+'</td>';
					s+= '<td width="80"  class="'+ct.msg[i].ys+'">';
					if(ct.msg[i].jyztStatus=="买入") {
						s+='<%=languageDefine.getValue(request, "js_myBuy")%>';
					}
					else {
						s+='<%=languageDefine.getValue(request, "js_mySell")%>';
					}
					s+='</td>';
					s+= '<td class="'+ct.msg[i].ys+'" >'+ct.msg[i].cjjg+'</td>';
					s+= '<td class="'+ct.msg[i].ys+'" >'+ct.msg[i].cjsl+'</td>';
					s+= '<td class="'+ct.msg[i].ys+'" >'+ct.msg[i].ycjsl+'</td>';
					s+= '<td class="'+ct.msg[i].ys+'" >'+ct.msg[i].ze+'</td>';
					s+= '<td width="80">';
					s+= '<a  href="javascript:void(0)" style="color: #e71414;"  onclick="cxwt('+ct.msg[i].wtid+','+ct.msg[i].scid+');"><%=languageDefine.getValue(request, "js_revoke")%></a>';
					s+= '</td>';
					s += '</tr>';
					content += s;
				}
				
				$("#entrustlist").html(content); 
			}else{ 
			 	 layer.open({
					title: '<%=languageDefine.getValue(request, "js_tip")%>',
					content:ct.msg
				});  	
			 } 
		}
	});	
	}
	
 	function cxwt(wtid,scid){//撤销委托
		var data = {"scid" : scid,"wtid":wtid};
		$.ajax({
			type : "post",
			dataType : "html",
			url : cxwt_url,
			data : data,
			success : function(data) {
				var ct = eval('(' + data + ')');
				if (ct.num>0) {
					wdwt();
					zh();
				}else{
					console.log(ct.msg);
					layer.open({
						title: '<%=languageDefine.getValue(request, "js_tip")%>',
						content:ct.msg
						}); 	
				}
			}
		});	
		
	} 
	
	
	function tadding_mr(price,num,paypassword){//买单提交
		var data = {"scid" : scid,"price":price,"num":num,"pwtrade":paypassword};
		$.ajax({
			type : "post",
			dataType : "html",
			url : trading_mr_url,
			data : data,
			success : function(data) {
				var ct = eval('(' + data + ')');
				if (ct.num>0) {
					wdwt();
					zh();
				}else{
					layer.open({
						title: '<%=languageDefine.getValue(request, "js_tip")%>',
						content:ct.msg.indexOf("err_")!=-1?eval("_error_global."+ct.msg):ct.msg
						}); 	
					
				}
			}
		});	
	}
		function tradeadd_buy(){//买单
		var mr_max=<%=b.mr_max%>;
		var mr_min=<%=b.mr_min%>;
		var dqj=<%=b.dqj%>;
		   var price =$('#buy_price').val();
	       var num =$('#buy_num').val();
	       var paypassword = $('#buy_paypassword').val();
	       if (price == "" || price == null||price<=0) {
	           layer.tips('<%=languageDefine.getValue(request, "js_enterPrice")%>', '#buy_price', {tips: 3});
	           return false;
	       }
	       if (num == "" || num == null||num <=0) {
	           layer.tips('<%=languageDefine.getValue(request, "js_enterQuantity")%>', '#buy_num', {tips: 3});
	           return false;
	       }
	       var zj=price*num;
	       if(zj<mr_min){
	    	   layer.tips('<%=languageDefine.getValue(request, "js_cannotLessThan")%>'+mr_min+'<%=languageDefine.getValue(request, "js_yuan")%>', '#buy_num', {tips: 3});
	    	   return false;
	       }
	       if(zj>mr_max){
	    	   layer.tips('<%=languageDefine.getValue(request, "js_cannotMoreThan")%>'+mr_max+'<%=languageDefine.getValue(request, "js_yuan")%>', '#buy_num', {tips: 3}); 
	    	   return false;
	       }
	       if(price>(dqj*2)){
			    	if (!window.confirm('<%=languageDefine.getValue(request, "js_isConfirmBuy")%>')) {
			   			return;
			   		}
			}
	       tadding_mr(price,num,paypassword);
	       $("#buy_price").val("");
	       $("#buy_num").val("");
	       $("#buy_paypassword").val("");
}

		function trading_mc(price,num,paypassword){//卖单提交
			var data = {"scid" : scid,"price":price,"num":num,"pwtrade":paypassword};
			$.ajax({
				type : "post",
				dataType : "html",
				url : trading_mc_url,
				data : data,
				success : function(data) {
					var ct = eval('(' + data + ')');
					if (ct.num>0) {
						wdwt();
						zh();
					}else{
						layer.open({
							title: '<%=languageDefine.getValue(request, "js_tip")%>',
							content:ct.msg.indexOf("err_")!=-1?eval("_error_global."+ct.msg):ct.msg
							}); 	
						
					}
				}
			});	
		}
		
function tradeadd_sell(){//卖单
	var mc_max=<%=b.mc_max%>;
	var mc_min=<%=b.mc_min%>;	
	var dqj=<%=b.dqj%>;
	 var price =$('#sell_price').val();
     var num =$('#sell_num').val();
     var paypassword = $('#sell_paypassword').val();
     if (price == "" || price == null||price<=0) {
         layer.tips('<%=languageDefine.getValue(request, "js_enterPrice")%>', '#sell_price', {tips: 3});
         return false;
     }
     if (num == "" || num == null||num <=0) {
         layer.tips('<%=languageDefine.getValue(request, "js_enterQuantity")%>', '#sell_num', {tips: 3});
         return false;
     }
     var zj=price*num;
     if(zj<mc_min){
  	   layer.tips('<%=languageDefine.getValue(request, "js_cannotLessThan")%>'+mc_min+'<%=languageDefine.getValue(request, "js_yuan")%>', '#sell_num', {tips: 3});
  	   return false;
     }
     if(zj>mc_max){
  	   layer.tips('<%=languageDefine.getValue(request, "js_cannotMoreThan")%>'+mc_max+'<%=languageDefine.getValue(request, "js_yuan")%>', '#sell_num', {tips: 3}); 
  	   return false;
     }
     if((price*2)<dqj){
		 if (!window.confirm('<%=languageDefine.getValue(request, "js_isConfirmSell")%>')) {
				return;
			}
       }
     trading_mc(price,num,paypassword);
     $("#sell_price").val("");
     $("#sell_num").val("");
     $("#sell_paypassword").val("");
}

	function moshi(i) {
		$('.trade_moshi').removeClass('on');
		$('#trade_moshi_' + i).addClass('on');
		if (i == 1) {
			$("#selllist").show();
			$("#buylist").show();
		}
		if (i == 3) {
			$("#selllist").hide();
			$("#buylist").show();
	
		}
		if (i == 4) {
			$("#selllist").show();
			$("#buylist").hide();
	
		}
	}
	function buy_ell(jg, type) {
		if (type == 1) {
			$("#sell_price").val(jg); 
		}
		if (type == 2) {
			$("#buy_price").val(jg); 
		}
	}
	
	
	var mr_sxfl =<%=b.mr_sxfl%>//买入手续费率
	var ws=<%=b.ws%>//位数
	function mr_max_km(){//最大可买
	 var mr_je=parseFloat($("#buy_price").val());//买入价格
	 var km=((parseFloat(cny_ky)/mr_je)).toFixed(8); 
	 var max_km=km.substring(0,km.lastIndexOf('.')+(ws+1));
	if(mr_je>0&&mr_je!=""){
	$("#buy_max").html(max_km);
	 }
	}
	function mr_sl(bl,i){
	if(i==1){
	var mr_je=parseFloat($("#buy_price").val());//买入价格
	var zs=parseFloat($("#buy_max").html());
	var mr_zj=(mr_je*bl*zs).toFixed(2);
	var mr_sl=(zs*bl).toFixed(ws);//买入数量
	if(mr_sl==''||mr_sl=='NaN'){
		mr_sl=0;
	}
	$("#buy_num").val(mr_sl);
	if(mr_zj==''||mr_zj=='NaN'){
		mr_zj=0;
	}
	$("#zj_mum").html(mr_zj);//总价
	}else{
		   var mc_je=parseFloat($("#sell_price").val());//卖出价格
		   var mc_zj=(mc_je*bl*parseFloat(xlb_ky)).toFixed(2);
		   var mc=(parseFloat(xlb_ky)*bl).toFixed(8);
		   var mc_sl=mc.substring(0,mc.lastIndexOf('.')+(ws+1));
		   if(mc_sl==''||mc_sl=='NaN'){
			   mc_sl=0;
			}
		   $("#sell_num").val(mc_sl);//卖出数量
		   if(mc_zj==''||mc_zj=='NaN'){
			   mc_zj=0;
			}
		   $("#zj_sell_mum").html(mc_zj);//总价
	}
	}
	function  zj(i){
	if(i==1){
	var mr_je=parseFloat($("#buy_price").val());//买入价格
	var sl= parseFloat($("#buy_num").val());//买入数量
	var zj=(mr_je*sl).toFixed(2);//总价
	if(zj<0||zj==''||zj=='NaN'){
		zj=0;
	}
	$("#zj_mum").html(zj);
	}else{
		var mc_je=parseFloat($("#sell_price").val());//卖出价格
		 var sl= parseFloat($("#sell_num").val());//卖出数量
		 var zj=(mc_je*sl).toFixed(2);//总价
		 if(zj<0||zj==''||zj=='NaN'){
				zj=0;
			}
		 $("#zj_sell_mum").html(zj);
	}
	}
	function s4(i){
	mr_sl(1/4,i); 
	}
	function s3(i){
	mr_sl(1/3,i); 
	}
	function s2(i){
	mr_sl(1/2,i); 
	}
	function s1(i){
	mr_sl(1,i); 
	}

	function my_je_zj(){//买入输入价格总价变
		 var mr_je=parseFloat($("#buy_price").val());//买入价格
		 var mrsl=parseFloat($("#buy_num").val());//买入数量
		 var zj=mr_je*mrsl;
		 $("#zj_mum").html(zj);
	}
	function mc_je_zj(){//卖出输入价格总价变
		 var mc_je=parseFloat($("#sell_price").val());//买入价格
		 var mcsl=($("#sell_num").val());//买入数量
		 var zj=mc_je*mcsl;
		 $("#zj_sell_mum").html(zj);
	}	
	$("#buy_best_price").click(function(){//最佳买价
			var m=$("#buy_best_price").html();
			var mj=m.replace(",","");
			 $("#buy_price").val(mj);
			 mr_max_km();
	});

	$("#sell_best_price").click(function(){//最佳卖价
		var m=$("#sell_best_price").html();
		var mj=m.replace(",","");
		 $("#sell_price").val(mj);
});
	
	<%String error = controller.getPrompt(request, response, PromptLevel.ERROR);
	if (!StringHelper.isEmpty(error)) {%>
layer.open({
title: '<%=languageDefine.getValue(request, "js_tip")%>',
content: '<%=languageDefine.getValue(request,error)%>'
});
<%}%>		
	</script>
</body>
</html>

